﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Models;
using System.Web;
using System.Web.Security;

namespace Web
{
    public static class WebSession
    {
        public static User CurrentAdmin
        {
            get
            {
                if (HttpContext.Current.Session["CurrentAdmin"] == null)
                {
                    try
                    {
                        //IAdminRepository adminRepository = DIFactory.GetInstance<IAdminRepository>();
                        //HttpContext.Current.Session["CurrentAdmin"] = adminService.GetAdminByUsername(HttpContext.Current.User.Identity.Name);
                    }
                    catch
                    {
                        //Logger.Info("User have been expired and not got back. RedirectUrl: " + FormsAuthentication.DefaultUrl);
                        HttpContext.Current.Response.Redirect(FormsAuthentication.LoginUrl);
                    }
                }
                return (User)HttpContext.Current.Session["CurrentAdmin"];
            }
            set
            {
                HttpContext.Current.Session["CurrentAdmin"] = value;
            }
        }
    }
}
